using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;

using FullMotion.LiveForSpeed.InSim;

namespace OvalRaceControl
{
    class buttoncontroller
    {
        List<buttongroup> groups = new List<buttongroup>();
        List<LfsButton> buttons;

        public buttoncontroller(InSimHandler handler, Hashtable ht)
        {
            buttons = new List<LfsButton>(199);
            for (int i = 0; i < 199; i++)
            {
                buttons.Add(new LfsButton((byte)i));
            }

            buttongroup racerlist = new buttongroup(handler,ht);
            racerlist.GroupName = "Racer List";
            racerlist.ButtonIDMin = 0;
            racerlist.ButtonIDMax = 46;
            racerlist.X = 2;
            racerlist.Y = 2;
            racerlist.ButtonWidth = 40;
            racerlist.ButtonHeight = (byte)4.10;
            racerlist.ButtonList = buttons;
            racerlist.Create();
            racerlist.Specialize();
            groups.Add(racerlist);

            buttongroup RCMMenu = new buttongroup(handler,ht);
            RCMMenu.GroupName = "RCM Menu";
            RCMMenu.ButtonIDMin = 47;
            RCMMenu.ButtonIDMax = RCMMenu.ButtonIDMin + 6;
            RCMMenu.X = 40;
            RCMMenu.Y = 25;
            RCMMenu.ButtonWidth = 40;
            RCMMenu.ButtonHeight = 6;
            RCMMenu.ButtonList = buttons;   // Give the whole list with buttons through
            RCMMenu.Create();               // Create the specific buttons
            RCMMenu.Specialize();
            groups.Add(RCMMenu);


            buttongroup close = new buttongroup(handler, ht);

            close.GroupName = "Close";
            close.ButtonIDMin = 190;
            close.ButtonIDMax = 190;
            close.X = 180;
            close.Y = 5;
            close.ButtonWidth = 20;
            close.ButtonHeight = 9;
            close.ButtonList = buttons;
            close.Create();
            close.Specialize();
            groups.Add(close);

        }


        public void DisplayMenu(string MenuName)
        {
            for (int i = 0; i < groups.Count; i++)
            {
                buttongroup bg = groups[i];
                if (bg.GroupName.Equals(MenuName))
                {
                    bg.Display();
                }                
            }
        }

        public void HideMenu(string MenuName)
        {
            for (int i = 0; i < groups.Count; i++)
            {
                buttongroup bg = groups[i];
                if (bg.GroupName.Equals(MenuName))
                {
                    bg.Hide();
                }
            }
        }



    }
}
